package com.example.lvsuo.controller;
import com.example.lvsuo.entity.LogJob;
import com.example.lvsuo.entity.vo.xzhvo.Log;
import com.example.lvsuo.modal.Result;
import com.example.lvsuo.service.ILogJobService;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import com.example.lvsuo.entity.LogJob;
import com.example.lvsuo.modal.Result;
import com.example.lvsuo.service.ILogJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 工作日志表 前端控制器
 * </p>
 *
 * @author 心心念念
 * @since 2021-03-30
 */
@RestController
@RequestMapping("/logJob")
public class LogJobController {
@Autowired
    ILogJobService  ils;

    @PostMapping("/chaxun")
    public Result  getselect(@RequestBody Log map){
 PageHelper.startPage(map.getCurrentPage(),map.getPageSize());
        PageInfo pageInfo = new PageInfo(ils.lists(map));
        return    Result.back(pageInfo);

   }

    @PostMapping("/chakan")
    public Result  getselectchakan(@RequestBody Log map){
        List<Log>  list=ils.lipos(map);
        return    Result.back(list);

    }
    @PostMapping("/rizhileixing")
    public Result  rizhileixing(@RequestBody Log map){
        List<Log>  list=ils.rizhileixing(map);
      //  System.err.println(list);
        return    Result.back(list);

    }

    @PutMapping("/xiugai")
    public Result  xiugai(@RequestBody Log map){
        Integer  in=  ils.xiugai(map);
        return    Result.back(in);

    }
    /*删除*/
    @DeleteMapping("/shanchu")
    public Result  shanchu(@RequestBody Log map){
        //System.out.println(map);
        LogJob logJob = new LogJob();
        logJob.setId(Long.valueOf(map.getJobid().toString()));
        logJob.setJoblogSta("0");
        boolean b = ils.updateById(logJob);
        return    Result.back(null);

    }

    @PostMapping("/xuanranerji")
    public Result  xuanranerji(@RequestBody Log map){
        List<Log>  list=ils.xuanranerji(map);
        return    Result.back(list);

    }
    @PostMapping("/anjianchaxun")
    public Result  getAnjianselect(@RequestBody Log map){
     //   System.err.println(ils.getAnjianselect(map));
        PageHelper.startPage(map.getCurrentPage(),map.getPageSize());
        PageInfo pageInfo = new PageInfo(ils.getAnjianselect(map));
        return    Result.back(pageInfo);

    }

    @PutMapping("/tianjia")
    public Result  tianjia(@RequestBody Log map){
//        System.err.println(map.getWhatisPerson());
//        System.err.println(map.getLogtypeId());
//        System.err.println(map.getCaseLawId());
//        System.err.println(map.getClientId());
//        System.err.println(map.getJoblogStarttime());
//        System.err.println(map.getJoblogEnddtime());
//        System.err.println(map.getJoblogReportedtime());
//        System.err.println(map.getJoblogUpdatetime());
//        System.err.println(map.getJoblogStatus());
//        System.err.println(map.getJoblogText());
//        System.err.println(map.getJoblogSta());







        Integer ss=  ils.tianjia(map);



        return    Result.back(ss);

    }

    @PostMapping("/chaxunpop")
    public Result  chaxunpop(@RequestBody Log map){
  PageHelper.startPage(map.getCurrentPage(),map.getPageSize());
        PageInfo pageInfo = new PageInfo(ils.chaxunpop(map));
        return    Result.back(pageInfo);

    }

    @PostMapping("/digui")
        public  Result   digui() {
            return Result.back(ils.digui());
        }
    @Autowired
    ILogJobService iLogJobService;

    /**
     *添加
     * @return
     */
    @PostMapping
    public Result insertLogJob(@RequestBody LogJob logJob){
        iLogJobService.save(logJob);
        return Result.back("ok",200);
    }

}

